<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class UserWage extends Model
{
    use HasFactory;
    
    protected $fillable = [
        'user_id',
        'operate_id',
        'base',
        'subsidies',
        'rewards',
        'other_subsidies',
        'pension_insurance',
        'medical_insurance',
        'unemployment_insurance',
        'housing',
        'social_security',
        'tax',
        'net_salary',
        'pay_type',
        'remarks',
        'issue_date',

    ];

    const POSTONLY = [
        'user_id',
        'operate_id',
        'base',
        'subsidies',
        'rewards',
        'other_subsidies',
        'pension_insurance',
        'medical_insurance',
        'unemployment_insurance',
        'housing',
        'social_security',
        'tax',
        'net_salary',
        'pay_type',
        'remarks',
        'issue_date',
    ];

    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function user()
    {
        return $this->hasOne(User::class,'id','user_id')->select('id','name','status','basic_salary');
    }
}
